package net.board.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.board.db.BoardDAO;
import net.board.db.BoardBean;

public class BoardReplyView implements Action {
	 public ActionForward execute(HttpServletRequest request,HttpServletResponse response) 
	 	throws Exception{
		 	ActionForward forward = new ActionForward();
		 	
		 	request.setCharacterEncoding("UTF-8");
			response.setCharacterEncoding("UTF-8");
			response.setContentType("text/html; charset=UTF-8");
		 	
			BoardDAO boarddao=new BoardDAO();
	   		BoardBean boarddata=new BoardBean();
	   		System.out.println("일루옴?");
	   		int ID=Integer.parseInt(request.getParameter("ID"));
	   		
	   		boarddata=boarddao.getDetail(ID);
	   		
	   		if(boarddata==null){
	   			return null;
	   		}
	   		
	   		String url;
	   		int number = Integer.parseInt(request.getParameter("number"));

	   		if(number==1){
	   			url = "/Main/OldMain/Om_Main.jsp";
	   		}else if(number==3){
	   			url = "/Main/admin/Ad_Main.jsp";
	   		}
	   		else{
	   			url = "/Main/YoungMain/Ym_Main.jsp";
	   		}
	   		
	   		request.setAttribute("boarddata", boarddata);
	   		
	   		String pagename = "/board/qna_board_reply";
			request.setAttribute("page", pagename);
			request.setAttribute("number", number);
	   		forward.setRedirect(false);
	   		forward.setPath(url);
	   		return forward;
	}
}